<!doctype html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>讯搜测试</title>
    <link rel="stylesheet" href="__PUBLIC__/static/css/bootstrap.min.css">
</head>
<body>

    <div class="container">
        <div class="row">
            <div class="col-md-3">     <div class="panel panel-default">
                    <div class="panel-heading panel-title">左部分</div>
                    <div class="panel-body">
                        <ul class="list-group">
                            <li class="list-group-item"><a href="#">列表一</a></li>
                            <li class="list-group-item"><a href="#">列表一</a></li>
                            <li class="list-group-item"><a href="#">列表一</a></li>
                            <li class="list-group-item"><a href="#">列表一</a></li>
                            <li class="list-group-item"><a href="#">列表一</a></li>
                            <li class="list-group-item"><a href="#">列表一</a></li>
                            <li class="list-group-item"><a href="#">列表一</a></li>
                            <li class="list-group-item"><a href="#">列表一</a></li>
                            <li class="list-group-item"><a href="#">列表一</a></li>
                            <li class="list-group-item"><a href="#">列表一</a></li>
                            <li class="list-group-item"><a href="#">列表一</a></li>
                        </ul>
                    </div>
                </div></div>
            <div class="col-md-9">

                <div class="panel panel-default">
                    <div class="panel-heading panel-title">右部分</div>
                    <div class="panel-body">

                            <button type="button" id="btn1" data-loading-text="loading..." class="btn btn-primary">批量索引</button>

                            <button type="button" id="btn2" data-loading-text="loading..." class="btn btn-success">获取热门值</button>

                            <button type="button" id="btn3" data-loading-text="loading..." class="btn btn-info">修改文档</button>



                            <button type="button" id="btn5" data-loading-text="loading..." class="btn btn-danger">清空索引</button>
                            <div id="infomation_list"></div>
                    </div>

                    <div class="panel">
                        <div class="panel-body">
                            <div class="form-group">
                                <label for="">文档ID</label>
                                <input type="number" id="del_input" class="form-control">
                            </div>
                            <button type="button" id="btn4" data-loading-text="loading..." class="btn btn-warning">删除文档</button>
                        </div>
                    </div>

                    <div class="panel-body">
                        <form action="" method="post">
                            <div class="form-group">
                                <label for="">搜索关键词</label>
                                <div class=""><input type="text" id="keyword" name="keyword" value="大唐天下" class="form-control"></div>
                            </div>
                            <button type="button" id="btn-search" data-loading-text="搜索中..." class="btn btn-default">提交</button>
                        </form>

                        <div>
                            <ul class="list-group" id="search_list">

                            </ul>
                        </div>


                        <div>
                            <ul class="pagination" id="pagination">
                                <li><a href="javascript:void;">1</a></li>
                                <li><a href="javascript:void;">2</a></li>
                                <li><a href="javascript:void;">3</a></li>
                                <li><a href="javascript:void;">4</a></li>
                                <li><a href="javascript:void;">5</a></li>
                                <li><a href="javascript:void;">6</a></li>
                                <li><a href="javascript:void;">7</a></li>
                                <li><a href="javascript:void;">8</a></li>
                            </ul>
                        </div>
                    </div>



                </div>

            </div>
        </div>
    </div>


    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/static/js/bootstrap.min.js"></script>

    <script type="text/javascript">

        $('#btn1').click(function () {
            var btn =$(this).button('loading')
            $.get('{:U('xun/batch_index')}',function (data) {
                console.log(data);
            });
            btn.button('reset');

        });
        $('#btn2').click(function () {
            var btn =$(this).button('loading')
            var btn =$(this).button('loading')
            $.get('{:U('xun/batch_hot')}',function (data) {

                $('#infomation_list').html(data);
            });
            btn.button('reset');
        });
        $('#btn3').click(function () {
            var btn =$(this).button('loading')
            $.get('{:U('xun/batch_edit')}',function (data) {
                console.log(data);
            });
            btn.button('reset');
        });
        $('#btn4').click(function () {
            var btn =$(this).button('loading')
            var id =$('#del_input').val();
            $.get('{:U('xun/batch_delete')}',{id:id},function (data) {

            });
            btn.button('reset');
        });
        $('#btn5').click(function () {
//            var btn =$(this).button('loading')
//            $.get('{:U('xun/batch_clear')}',function (data) {
//                console.log(data);
//            });
            btn.button('reset');
        });

        $('#btn-search').click(function () {
            var btn =$(this).button('loading')
            var keyword =$.trim($('#keyword').val());
            search_page(keyword,1);
            btn.button('reset');
        });

        $('#pagination >li').find('a').click(function () {
            event.preventDefault();
            var id =$(this).text();
            var keyword =$.trim($('#keyword').val());
            search_page(keyword,id);
        })

        function search_page(keyword,page) {
            var html ="";
            $.get('{:U('xun/batch_search')}',{'key':keyword,'page':page},function (data) {
                $.each(data,function (i) {
                    html +='<li class="list-group-item"><span class="badge">'+this.create_time +'</span>['+ this.id + ']   ' + this.title+'</li>';
                });
                $('#search_list').html(html);

            });
        }


//        $('#keyword').keyup(function () {
//            var text =$(this).val();
//            console.log(text);
//            $.get('{:U('xun/getRelatedQuery')}',function (data) {
//                $('#search_list').html(data);
//            })
//
//        })

    </script>


</body>
</html>